<%@ page contentType="text/html;charset=utf-8" %>
<%@ page language="java" import="weibo4j.http.*" %>
<%@ page language="java" import="weibo4j.*" %>

<jsp:useBean id="weboauth" scope="session" class="weibo4j.examples.WebOAuth" />
<%
	
	String verifier=request.getParameter("oauth_verifier");
	
	if(verifier!=null)
	{
	System.out.println("这个等于oauth:"+verifier);
		RequestToken resToken=(RequestToken) session.getAttribute("resToken");

		if(resToken!=null)
		{
			AccessToken accessToken=weboauth.requstAccessToken(resToken,verifier);
				if(accessToken!=null)
				{   String opt=(String)session.getAttribute("opt");
     				session.setAttribute("accessToken",accessToken); 
				    if(opt.equals("1")){
                    out.println("5 秒后转到 writeWeibo.html");
                    Thread.sleep(5000);
                    //response.sendRedirect("http://192.168.1.71:8080/WeiBoSina/writeWeibo.html");//我现在改成传递到添加到涂四格页面
                    response.sendRedirect("http://192.168.1.71:8080/WeiBoSina/ComiCan.jsp");
				    }
				    if(opt.equals("2")){
				    out.println("5 秒后转到Favorites.jsp");
                    Thread.sleep(5000);
                    response.sendRedirect("http://192.168.1.71:8080/WeiBoSina/Favorites.jsp");
				    }
				    if(opt.equals("3")){
				    	
				    out.println("5 秒后转到pic.html");
                    Thread.sleep(5000);
                    response.sendRedirect("http://192.168.1.71:8080/WeiBoSina/pic.html");
				    }
					//out.println(accessToken.getToken());
					//out.println(accessToken.getTokenSecret());
					//第二个参数每次只能用一次，发表微博内容不能重复，如果重复发会返回400错误
					//这个accessToken不用每次访问都重新取，可以存到session里面用
					
					//weboauth.update(accessToken,"新的形式发表");
					//out.println("发表成功");				
				}else
					{
					out.println("access token request error");
					}
		
		}
		else
			{
			out.println("request token session error");
			}
	}
	else
		{
		out.println("verifier String error");
		}

%>   